function phase_1(pUnit, Event)
 if pUnit:GetHealthPct() < 99 then
  pUnit:RemoveEvents();
  pUnit:SendChatMessage(14, 0, "Chaos!")
  pUnit:CastSpellOnTarget(47248)
  pUnit:PlaySoundToSet(12505)
  pUnit:RegisterEvent("phase_2",1000, 0)
 end
end

function phase_2(pUnit, Event)
 if pUnit:GetHealthPct() < 98 then
  pUnit:RemoveEvents();
  pUnit:SendChatMessage(14, 0, "Destruction!")
  pUnit:CastSpell(39023)
  pUnit:PlaySoundToSet(12506)
  pUnit:RegisterEvent("phase_3",1000, 0)
 end
end
 
function phase_3(pUnit, Event)
 if pUnit:GetHealthPct() < 97 then
  pUnit:RemoveEvents();
  pUnit:SendChatMessage(14, 0, "Oblivion!")
  pUnit:PlaySoundToSet(12507)
  pUnit:CastSpell(38627)
  pUnit:CastSpell(38533)
  pUnit:CastSpell(38533)
  pUnit:CastSpell(38533)
  pUnit:RegisterEvent("phase_4",1000, 0)
 end
end
 
function phase_4(pUnit, Event)
 if pUnit:GetHealthPct() < 50 then
  pUnit:RemoveEvents();
  pUnit:SendChatMessage(14, 0, "I will not be denied! This world shall fall!")
  pUnit:PlaySoundToSet(12508)
  pUnit:CastSpell(45664)
  pUnit:RegisterEvent("phase_5",1000, 0)
 end
end
 
function phase_5(pUnit, Event)
 if pUnit:GetHealthPct() < 20 then
  pUnit:RemoveEvents();
  pUnit:SendChatMessage(14, 0, "Do not harbor false hope. You cannot win!")
  pUnit:PlaySoundToSet(12509)
  pUnit:CastSpell(40343)
  pUnit:CastSpell(38441)
  pUnit:CastSpell(512)
  pUnit:CastSpell(25442)
  pUnit:CastSpell(17668)
  pUnit:CastSpell(40876)
  pUnit:RegisterEvent("phase_6",1000, 0)
 end
end


function phase_6(pUnit, Event)
 if pUnit:GetHealthPct() < 01 then
  pUnit:RemoveEvents();
  pUnit:SendChatMessage(14, 0, "Ragh! The powers of the Sunwell turn against me! What have you done? What have you done?!")
  pUnit:PlaySoundToSet(12510)
  pUnit:CastSpell(44998)
  pUnit:RegisterEvent("phase_7",1000, 0)
 end
end

function phase_7(pUnit, Event)
 if pUnit:GetHealthPct() < 100 then
  pUnit:RemoveEvents();        
  pUnit:CastSpell(46474)
 end
end

function boss_start(pUnit, Event)
 pUnit:RegisterEvent("phase_1",1000, 0)
 end

function boss_OnKill(pUnit, Event)
  pUnit:SendChatMessage(14, 0, "Another step towards destruction!")
pUnit:PlaySoundToSet(12501)
  pUnit:CastSpell(31972)
 end


RegisterUnitEvent(25315, 1, "boss_start")
RegisterUnitEvent(25315, 3, "boss_OnKill")